home *** CD-ROM | disk | FTP | other *** search
- /* fgets.c */
- #include <stdio.h>
- main()
- {
- FILE *infile;
- char string[81];
- /* Open the file. Because of the special significance
- * of '\' in C, we need two of them in the path name for
- * autoexec.bat */
- if ((infile = fopen("c:\\autoexec.bat", "r")) == NULL)
- {
- printf("fopen failed.\n");
- exit(0);
- }
- printf ("Contents of c:autoexec.bat:\n");
- while (fgets(string, 80, infile) != NULL)
- {
- fputs(string,stdout);
- }
- }